package dom.domain;

import java.util.ArrayList;
import java.util.Map;

import net.sf.json.JSONObject;

/**
 * Score entity. @author MyEclipse Persistence Tools
 */

public class Score implements java.io.Serializable {

	// Fields

	private String userId;
	private String userSubType;
	private Double score;

	// Constructors

	/** default constructor */
	public Score() {
	}

	/** minimal constructor */
	public Score(String userId) {
		this.userId = userId;
	}

	/** full constructor */
	public Score(String userId, String userSubType, Double score) {
		this.userId = userId;
		this.userSubType = userSubType;
		this.score = score;
	}

	// Property accessors

	public String getUserId() {
		return this.userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserSubType() {
		return this.userSubType;
	}

	public void setUserSubType(String userSubType) {
		this.userSubType = userSubType;
	}

	public Double getScore() {
		return this.score;
	}

	public void setScore(Double score) {
		this.score = score;
	}
	
	@Override
	public String toString() {
		return "{userId:'" + userId + "', userSubType:'" + userSubType
				+ "', score:'" + score + "'}";
	}
	public ArrayList<String> getInfo(String key[])
	{
		JSONObject jInfo = JSONObject.fromObject(this.toString());
		ArrayList<String> arrayList = new ArrayList<String>();
		for(int i =0;i<key.length;i++)
		{
			arrayList.add(jInfo.getString(key[i]));
		}
		return arrayList;
	}
	public void setInfo(ArrayList<String> list,Map<String,String> userInfo)
	{
		for(int i = 0;i<list.size();i++)
		{
			if(list.get(i).equals("userId"))
			{
				this.setUserId(userInfo.get(list.get(i)));
			}
			if(list.get(i).equals("userSubType"))
			{
				this.setUserSubType(userInfo.get(list.get(i)));
			}
			if(list.get(i).equals("finalScore"))
			{
				this.setScore(Double.parseDouble(userInfo.get(list.get(i))));
			}
			
		}
	}

}